const mongoose = require('mongoose')

// 构建集合结构
const noticeSchema = new mongoose.Schema({
    tips: { //提示消息
        type: String,
        required: true
    },
    userId: { //操作人
        type: mongoose.SchemaTypes.ObjectId,
        ref: 'User'
    },
    taskId: { //任务id
        type: mongoose.SchemaTypes.ObjectId,
        ref: 'Task'
    },
    notifier:[{ //通知人
        type: mongoose.SchemaTypes.ObjectId,
        ref: 'User'
    }],
    operate: { //操作名称 0提交 1更新 2分解 3删除 4通过审核 5打回 6提醒 
        type: Number,
        enum: [0, 1, 2, 3, 4, 5, 6],
        required: true
    },
    isRead: { //是否已读 true已读 false未读
        type: Boolean,
        default: false
    }
}, {
    // 创建时间和更新时间
    timestamps: true
})

module.exports = mongoose.model('Notice', noticeSchema, 'notice')